
package seeqpod;

public class SeeqPod {

    static String KEY = "c9b619b61b27e61a12e6a584adc09dd689e4805c";

    public static void main(String[] args) {
        SeeqPod sp = new SeeqPod();

        sp.search("311");
        sp.recommend("sublime", "smoke two joints");
        sp.spellcheck("50 cents");
    }

    SeeqPodTrack[] search(String query) {
        SearchSeeqResultsThread ssrt = new SearchSeeqResultsThread(query, KEY, 0, 10);
        try {
            ssrt.start();
            ssrt.join();
        } catch (InterruptedException ex) {
            System.out.println("Thread Interrupted");
            return null;
        }
        return ssrt.getTracks();
    }

    SeeqPodTrack[] search(String query, int startIndex) {
        SearchSeeqResultsThread ssrt = new SearchSeeqResultsThread(query, KEY, startIndex, 10);
        try {
            ssrt.start();
            ssrt.join();
        } catch (InterruptedException ex) {
            return null;
        }
        return ssrt.getTracks();
    }

    SeeqPodTrack[] search(String query, int startIndex, int numResults) {
        SearchSeeqResultsThread ssrt = new SearchSeeqResultsThread(query, KEY, startIndex, numResults);
        try {
            ssrt.start();
            ssrt.join();
        } catch (InterruptedException ex) {
            System.out.println("Thread Interrupted");
            return null;
        }
        return ssrt.getTracks();
    }

    public SeeqPodRecommendation[] recommend(String artist, String song) {
        InOut io = new InOut();
        artist = artist.replaceAll(" ", "%20");
        song = song.replaceAll(" ", "%20");
        return io.DiscoverSeeqResults(artist, song);
    }

    public SeeqPodSpellCheck[] spellcheck(String query) {
        InOut io = new InOut();
        query = query.replaceAll(" ", "%20");
        return io.SeeqPodSpell(query, KEY);
    }
}
